<template>
    <div class="page">
        <div class="header">
            <img class="logo" src="@/assets/logo.png" alt="" />
            <img class="language" src="@/assets/EN-17.png" v-if="locale == 'zh-CN'" alt="" @click="toggleLang()" />
            <img class="language" src="@/assets/CH-17.png" v-else alt="" @click="toggleLang()" />
        </div>
        <!-- <div class="search">
            <div class="title">{{ $t("sou-suo-ye-zhu") }}</div>
            <div class="input_box">
                <input class="input" type="text" :placeholder="$t('qing-shu-ru-ye-zhu-ming-cheng')" v-model="key" />
                <img class="search_btn" src="@/assets/search_btn.png" alt="" @click="handleSearchInput" />
            </div>
        </div> -->
        <div class="hotel_name">
            {{
                locale == "zh-CN"
                    ? hotel_info?.holidex + " - " + hotel_info?.hotel_name_zh
                    : hotel_info?.holidex + " - " + hotel_info?.brand + " " + hotel_info?.hotel_name
            }}
        </div>
        <div class="list">
            <div class="list_l">
                <template v-if="list.length">
                    <div class="item" v-for="(item, index) in list" :key="index">
                        <div class="owner_num">
                            <img src="@/assets/owner_icon.png" alt="" />
                            <span>{{ $t("ye-zhu") }}{{ index + 1 }}</span>
                        </div>
                        <div class="owner_detail">
                            <div class="name">
                                {{
                                    locale == "zh-CN"
                                        ? item.ch_name + (item.title_int == 1 ? " 先生" : " 女士")
                                        : (item.title_int == 1 ? "Mr. " : "Ms. ") + item.en_name
                                }}
                            </div>
                            <div class="hang">
                                <div class="title">{{ $t("qi-wei-zhang-hao") }}</div>
                                <div class="content">{{ item.has_user_id == 1 ? $t("shi") : $t("bu-shi") }}</div>
                            </div>
                            <div class="hang">
                                <div class="title">{{ $t("gong-si-ming-cheng") }}</div>
                                <div class="content">
                                    {{ locale == "zh-CN" ? item.ch_company_name : item.en_company_name }}
                                </div>
                            </div>
                            <div class="hang">
                                <div class="title">{{ $t("zhi-wei") }}</div>
                                <div class="content">{{ locale == "zh-CN" ? item.ch_job : item.en_job }}</div>
                            </div>
                            <div class="hang" v-if="item.phone_main">
                                <div class="title">{{ $t("chang-yong-lian-xi-dian-hua") }}</div>
                                <div class="content">{{ item.phone_main }}</div>
                            </div>
                            <div class="hang" v-if="item.phone_other">
                                <div class="title">{{ $t("qi-ta-lian-xi-dian-hua") }}</div>
                                <div class="content">{{ item.phone_other }}</div>
                            </div>

                            <div class="hang" v-if="item.email_main">
                                <div class="title">{{ $t("chang-yong-you-xiang") }}</div>
                                <div class="content">{{ item.email_main }}</div>
                            </div>
                            <div class="hang" v-if="item.email_other">
                                <div class="title">{{ $t("qi-ta-you-xiang") }}</div>
                                <div class="content">{{ item.email_other }}</div>
                            </div>
                            <div class="hang" v-if="item.address">
                                <div class="title">{{ $t("di-zhi") }}</div>
                                <div class="content">
                                    {{ locale == "zh-CN" ? item.address : item.address }}
                                </div>
                            </div>
                            <div class="hang" v-if="item.remark">
                                <div class="title">{{ $t("bei-zhu") }}</div>
                                <div class="content">{{ locale == "zh-CN" ? item.remark : item.remark }}</div>
                            </div>
                            <div class="hang">
                                <div class="title">{{ $t("jiao-se") }}</div>
                                <div class="content">
                                    {{
                                        locale == "zh-CN"
                                            ? item.role_arr.length
                                                ? item.role_arr.join(",")
                                                : ""
                                            : item.role_arr_en
                                            ? item.role_arr_en.join(",")
                                            : ""
                                    }}
                                </div>
                            </div>
                            <div class="hang" v-if="role_other">
                                <div class="title">{{ $t("qi-ta") }}</div>
                                <div class="content">{{ item.role_other }}</div>
                            </div>
                            <div class="hang">
                                <div class="title">{{ $t("ye-wu-chang-jing") }}</div>
                                <div class="content">
                                    {{
                                        locale == "zh-CN"
                                            ? item.scenario_arr.length
                                                ? item.scenario_arr.join(",")
                                                : ""
                                            : item.scenario_arr_en.length
                                            ? item.scenario_arr_en.join(",")
                                            : ""
                                    }}
                                </div>
                            </div>
                        </div>
                    </div>
                </template>
                <div v-else class="empty"><van-empty :description="$t('mei-you-geng-duo-shu-ju-le')" /></div>
            </div>
        </div>
    </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { owner_list } from "@/api/ownerList";
import { showLoadingToast, showToast } from "vant";
import { useLanguage } from "@/hooks/useLanguage";
import { useRoute } from "vue-router";

const { toggleLang, locale, t } = useLanguage();
const route = useRoute();

//当前酒店
const hotel_info = ref(null);

//搜索条件
const key = ref("");

//数据列表
const list = ref([]);
//搜索
const handleSearchInput = () => {
    list.value = [];
    getList();
};
//查询业主列表
const getList = async () => {
    let slt = "";
    try {
        slt = showLoadingToast({
            message: t("jia-zai-zhong"),
            forbidClick: true,
        });
        let res = await owner_list({
            hotel_id: hotel_info.value?.id,
            key: key.value,
        });
        if (res.data.length == 0) {
            showToast(t("mei-you-geng-duo-shu-ju-le"));
            return;
        }
        list.value = res.data;
    } finally {
        slt.close();
    }
};

//获取

onMounted(() => {
    if (sessionStorage.getItem("hotel_info")) {
        hotel_info.value = JSON.parse(sessionStorage.getItem("hotel_info"));
        getList();
    }
});
</script>
<style lang="scss" scoped>
.page {
    width: 100%;
    height: 100vh;
    background-image: url("@/assets/bg.png");
    background-size: cover;
    background-repeat: no-repeat;
    padding: 0 30px;
}
.header {
    width: 100%;
    height: 114px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .logo {
        width: 186px;
        height: 33px;
    }

    .language {
        width: 80px;
        height: 34px;
    }
}

.search {
    width: 100%;
    height: 214px;
    background-image: url("@/assets/search_bg.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
    padding: 0 30px;
    margin-bottom: 40px;

    .title {
        width: 100%;

        font-weight: bold;
        font-size: 38px;
        color: #ffffff;
        padding-top: 25px;
        padding-left: 120px;
    }

    .input_box {
        width: 100%;
        height: 88px;
        margin-top: 30px;
        position: relative;
        display: flex;
        align-items: center;

        .input {
            width: 100%;
            height: 88px;
            background: #ffffff;
            border-radius: 44px;
            border: 4px solid #e8542c;
            outline: none;
            text-indent: 1em;

            font-weight: 400;
            font-size: 30px;
            color: #999999;
        }

        .search_btn {
            width: 60px;
            height: 60px;
            position: absolute;
            right: 20px;
            bottom: 50%;
            transform: translateY(50%);
        }
    }
}

.hotel_name {
    width: 100%;
    min-height: 120px;
    background: #214658;
    border-radius: 26px 26px 0 0;
    border: 2px solid #eef6ff;
    font-weight: bold;
    font-size: 38px;
    color: #ffffff;
    line-height: 38px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 10px;
    // padding: 30px 30px 0 30px;
}

.list {
    width: 750px;
    // height: calc(100vh - 114px - 214px - 40px - 100px);
    height: calc(100vh - 114px - 100px);
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 0 30px;

    .list_l {
        width: 100%;
        height: 100%;
        overflow: auto;

        .item {
            width: 100%;
            // min-height: 912px;
            background: #d8e8f0;
            border-radius: 26px;
            border: 1px solid #ffffff;
            margin-bottom: 30px;
            padding: 30px;

            .owner_num {
                display: flex;
                align-items: center;
                font-weight: bold;
                font-size: 26px;
                color: #e8542c;
                line-height: 39px;
                margin-bottom: 23px;

                img {
                    width: 30px;
                    height: 30px;
                    margin-right: 13px;
                }
            }

            .owner_detail {
                width: 100%;
                // min-height: 801px;
                background: #ffffff;
                border-radius: 20px;
                padding: 0 30px 30px 30px;

                .name {
                    width: 100%;
                    min-height: 96px;

                    font-weight: 500;
                    font-size: 34px;
                    color: #292929;
                    line-height: 39px;
                    display: flex;
                    align-items: center;
                    justify-content: flex-start;
                    border-bottom: 1px solid #e6e6e6;
                }

                .hang {
                    width: 100%;
                    display: flex;
                    margin: 25px 0;

                    font-weight: 400;
                    font-size: 30px;
                    line-height: 39px;
                    word-break: break-word;
                    .title {
                        color: #999999;
                        min-width: fit-content;
                        width: fit-content;
                    }

                    .content {
                        color: #292929;
                        flex: 1;
                    }
                }
            }
        }

        .empty {
            width: 100%;
            background-color: #fff;
            border-radius: 26px;
        }
    }
}
</style>
